<include file="Public:header" />
<div class="wrapper wrapper-content animated fadeIn">
    <div class="row">
	    <div class="col-lg-12">
			<div class="title-bar">
				<div class="row " id="title-show">
					<ul class="nav pull-left" style="margin:0px 10px 0px 20px;">
						<span>
							<img src="__PUBLIC__/img/contract_view_icon.png" style="margin-bottom:9px;" alt="">
						</span>
						<span style="font-size:21px;margin-left:5px">&nbsp;&nbsp;&nbsp;{$order_info['code']}</span>&nbsp;&nbsp; 
						<if condition="$order_info['check_state'] eq 1">
							<span class="badge badge-success check_badge" style="padding:5px 20px;margin-top:-8px;background:#8BC34A;color:#fff;">已接单</span>&nbsp;
						<elseif condition="$order_info['check_state'] eq 2"/>
							<span class="badge badge-error check_badge" style="color:#fff;padding:5px 20px;margin-top:-8px;background:#F5715F">已取消</span>&nbsp;
						<else />
							<span class="badge badge-warning" style="color:#fff;padding:5px 20px;margin-top:-8px;background:#F5CA00">未接单</span>
						</if>
					</ul>
					<if condition = "checkPerByAction('order','check')">
						<if condition="$order_info['check_state'] eq 0">
							<input type="hidden" id="is_checked" value="1"/>
							<a href="javascript:void(0);" id="check_contract" style="margin-right:15px;" rel="{$order_info['order_id']}" class="btn btn-primary pull-right">接单</a>
						<else/>
							<input type="hidden" id="is_checked" value="0"/>
							<a href="javascript:void(0);" id="check_contract" style="margin-right:15px;" rel="{$order_info['order_id']}" class="btn btn-primary pull-right">取消订单</a>
						</if>
					</if>
				</div>
			</div>
			<div class="tabs-container">
				<div class="pull-left" style="width:64%;">
					<div class="ibox-content" style="padding:15px 0 0 20px;background:#fff;" id="left-content">
						<ul class="nav nav-tabs" id="left_list" style="height:40px;">
							<li class="active" ><a href="#tab1" data-toggle="tab" type="tab1">基本信息</a></li>
							<li><a href="#tab2" data-toggle="tab" type="tab2">产品信息</a></li>
						</ul>
						<div class="tab-content ">
							<div class="tab-pane in active " id="tab1">
								<div class="panel-body ">
									<include file="Public:alert" />
									<div style="font-size:13px;font-weight:700;margin:15px auto;"><span style="border-left:5px solid #19AA8D;padding-left:10px;height:10px;"></span>基本信息</div>
									<div class="form-horizontal view-group " style="margin-left:-10px;">
										<div class="form-group">
											<label class="col-lg-2 control-label">订单编号</label>
											<div class="col-lg-4">
												<p class="form-p">
													{$order_info['code']}
												</p>
											</div>
											<label class="col-lg-2 control-label">创建时间</label>
											<div class="col-lg-4">
												<p class="form-p">
													{$order_info.create_time|date="Y-m-d",###}
												</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-2 control-label">签约{:L('CUSTOMER')}</label>
											<div class="col-lg-4">
												<p class="form-p">
													<a href="{:U('member/view','id='.$order_info['member_id'])}">{$order_info['member_info']['name']}</a>
												</p>
											</div>
											<label class="col-lg-2 control-label">订单金额</label>
											<div class="col-lg-4">
												<p class="form-p">
													{$order_info['price']}
												</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-2 control-label">订单阶段</label>
											<div class="col-lg-4">
												<p class="form-p">
													{$order_info['status_name']}
												</p>
											</div>
											<label class="col-lg-2 control-label">支付状态</label>
											<div class="col-lg-4">
												<p class="form-p">
													{$order_info['payment_state_name']}</a>
												</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-2 control-label">订单备注</label>
											<div class="col-lg-10" style="margin-top: 6px;width: 70%;">
												<span style="line-height: 22px;">
													{$order_info['remark']}
												</span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-2 control-label">收货地址</label>
											<div class="col-lg-10" style="margin-top: 6px;width: 70%;">
												<span style="line-height: 22px;">
													{$order_info['address']}
												</span>
											</div>
										</div>
									</div>
									<div style="font-size:13px;font-weight:700;margin-top:20px;margin-bottom:15px;">
										<span style="border-left:5px solid #19AA8D;padding-left:10px;height:10px;"></span>审核信息
									</div>
									<div>
										<div class="pull-left">
											<img src="{$info['user_img']}" style="width:45px;height:45px;margin:10px 0 0 10px;border-radius:50px;" />
										</div>
										<div class="pull-left" style="margin:10px 0 0 10px;">
											<div class="control-label" style="margin-top:2px;font-size:14px;color:#B4B1C2"><a href="javascript:void(0)" rel="{$info['creator_role_id']}" class="role_info" style="color: #B4B1C2;">{$info['creator_name']}</a></div>
											<div class="control-label" style="margin-top:2px;font-size:13px;">{$info.create_time|date="Y-m-d H:i",###}</div>
										</div>
										<div class="pull-left" style="margin-left:6%;margin-top:25px;">
											<span class="fa fa-circle" style="color:#B4B1C2;font-size:12px;"></span>
											<span class="fa fa-circle" style="color:#B4B1C2;font-size:12px;"></span>
											<span class="fa fa-circle" style="color:#B4B1C2;font-size:12px;"></span>
										</div>
										<div class="pull-left" style="margin-left:6%;">
											<if condition="$info['is_checked'] eq 0">
												<img src="__PUBLIC__/img/moren.png" style="width:45px;height:45px;margin:10px 0 0 10px;border-radius:50px;">
											<else/>
												<img src="{$info['examine_role_img']}" style="width:45px;height:45px;margin:10px 0 0 10px;border-radius:50px;">
											</if>
										</div>
										<div class="pull-left" style="margin:10px 0 0 10px;">
											<div class="control-label" style="margin-top:2px;font-size:14px;color:#B4B1C2">
												<if condition="$info['is_checked'] neq 0">
													<a href="javascript:void(0)" rel="{$info['examine_role_id']}" class="role_info" style="color: #B4B1C2;">{$info['examine_role_name']}</a>
												<else/>
													合同审核员
												</if>
											</div>
											<div class="control-label check_badge" style="margin-top:2px;font-size:13px;">
												<if condition="$info['is_checked'] eq 1">
													<span style="color:#19AA8D">通过</span>
												<elseif condition="$info['is_checked'] eq 2"/>
													<span style="color:#F5715F">拒绝</span>
												<else />
													<span style="color:#F5CA00">待审</span>
												</if>
												<if condition="checkPerByAction('contract','check') && $info['is_checked'] gt 0">
													&nbsp;<a class="backbtn control" style="display:none;" href="{:U('contract/revokecheck', 'id='.$info['contract_id'])}"><i class="icon-repeat"></i> 撤销</a>
												</if>
											</div>
										</div>
										<div style="clear:both"></div>
									</div>
								</div>
							</div>
							<div class="tab-pane" id="tab2">
								<div class="panel-body" style="padding-left:0px;">
									<table class="table table-bordered" id="no-input-border" width="95%" border="0" cellspacing="1" cellpadding="0">
										<thead>
											<tr style="background-color:#f9fafc;text-align:center;">
												<td style="background-color:#f9fafc;padding:14px;color:#999">产品名称</td>
												<td style="background-color:#f9fafc;padding:14px;color:#999">价格(元)</td>
												<td style="background-color:#f9fafc;padding:14px;color:#999">销售单价(元)</td>
												<td style="background-color:#f9fafc;padding:14px;color:#999">数量</td>
												<td style="background-color:#f9fafc;padding:14px;color:#999">单位</td>
												<td style="background-color:#f9fafc;padding:14px;color:#999">小计</td>
											</tr>
										</thead>
										<tbody>
											<volist name="order_info['product_list']" id="vo">
												<tr id="row_{$key+1}">
													<td style="text-align:center;padding:14px;color:#666">{$vo['product_info']['name']}</td>
													<td style="text-align:center;padding:14px;color:#666">{$vo['ori_price']}</td>                                   
													<td style="text-align:center;padding:14px;color:#666">{$vo['unit_price']}</td>
													<td style="text-align:center;padding:14px;color:#666">{$vo['amount']}</td>
													<td style="text-align:center;padding:14px;color:#666">{$vo['unit']}</td>
													<td style="text-align:center;padding:14px;color:#666">{$vo['subtotal']}</td>
												</tr>
											</volist>
										</tbody>
									</table>
									<div style="text-align:center;margin-top:10px;">
										<div class="pull-right">销售订单金额(元) :<span style="color:#FF9900;">&nbsp;{$order_info['price']}</span></div>&nbsp;&nbsp;
										<!-- <div class="pull-right"><i class="fa fa-bookmark" style="color: #19aa8d;"></i>&nbsp;相关订单:<span style="color:#999;">&nbsp;{$order_info['code']}&nbsp;</span></div>&nbsp;&nbsp; -->
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="pull-right" style="width:35%;margin-left:0px;margin-bottom: 10px;">
					<div class="back_box bg_border ibox-content" style="padding:15px;background:#fff;margin-bottom:10px;">
						<div style="border-bottom: 1px solid #e7eaec;padding-bottom:10px;">
							<i style="font-size:18px;padding-left:10px;margin-top:2px;color:#B4B1C2" class="fa fa-cny"></i>
							<span style="padding:10px 20px 5px 10px;font-size:16px;">应收款</span>
						</div>
						<table class="table" style="margin-top:10px;">
							<tbody>
								<tr>
									<td style="color:#AFAFAF;border:none;font-weight:700">收款金额</td>
									<td style="color:#AFAFAF;border:none;font-weight:700">收款进度</td>
									<td style="color:#AFAFAF;border:none;font-weight:700;margin-left:15px;">应收款时间</td>
								</tr>
								<tr>
									<td style="border:none;color:#8FD168;font-weight:700;font-size:16px;"><if condition="$receivables['price'] gt 0">{$receivables['price']}<else/> 0</if>&nbsp;元</td>
									<td style="border:none;">
										<small>当前进度：{$receivables['schedule']}%</small>
										<div class="progress progress-mini">
			                                <div style="width: {$receivables['schedule']}%;" class="progress-bar"></div>
			                            </div>
									</td>
									<td style="border:none;color:#AFAFAF;font-size:16px;margin-left:15px;">{$receivables['pay_time']|date="Y-m-d",###}</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="back_box bg_border ibox-content" style="padding:15px;background:#fff;" id="right-content">
						<div style="height:35px;border-bottom: 1px solid #e7eaec;background:#fff;margin-bottom:15px;">
							<i style="font-size:18px;padding-left:10px;margin-top:2px;color:#B4B1C2" class="fa fa-cny"></i>
							<span style="padding:10px 20px 5px 10px;font-size:16px;">回款</span>
							<if condition="$info['is_checked'] eq 1">
								<a href="javascript:void(0);" class="pull-right" id="add_receivingorder" title="添加回款" style="padding-right:20px;"><i class="fa fa-plus" style="font-size:18px;color:#B4B1C2"></i></a>
							</if>
						</div>
						<if condition="$info['is_checked'] eq 1">
							<div style="font-size:16px;margin-bottom:10px;margin-left:5px;">合计：{:number_format($receivables['price'],2)}&nbsp;元 / <span style="color:#FB8C57">未收款:  {$receivables['un_payable']}&nbsp;元</span></div>
						<else/>
							<div style="font-size:16px;margin-bottom:10px;margin-left:5px;">合计：0&nbsp;元 / <span style="color:#FB8C57">未收款:  0&nbsp;元</span></div>
						</if>
						<table class="table">
							<thead>
								<tr style="background-color:#F5F5F6;">
									<td style="color:#7D919F">回款时间</td>
									<td style="color:#7D919F">回款金额</td>
									<td style="color:#7D919F">回款账号</td>
									<td style="color:#7D919F">回款人</td>
									<td style="color:#7D919F">状态</td>
									<td style="color:#7D919F"  style="cursor:pointer;height:3rem;color:#8FA1B2">操作</td>
								</tr>
							</thead>
							<tbody>
								<volist name="receivingorder" id="vo">
									<tr >
										<td><a href="{:U('finance/view', 't=receivingorder&id='.$vo['receivingorder_id'])}">{$vo.pay_time|date="Y-m-d",###}</a></td>
										<td><a href="{:U('finance/view', 't=receivingorder&id='.$vo['receivingorder_id'])}">{$vo.money}</a></td>
										<td><a href="{:U('finance/view', 't=receivingorder&id='.$vo['receivingorder_id'])}">{$vo.receipt_account}</a></td>
										<td><a class="role_info" href="javascript:void(0)" rel="{$vo2['owner_role_id']}">{$vo.user_name}</a></td>
										<td class="check_badge">
											<if condition="$vo['status'] eq 1">
												已通过
											<elseif condition="$vo['status'] eq 2"/>
												已拒绝
											<else />
												待审核
											</if>
											<!-- <if condition="$vo['status'] eq '0' && checkPerByAction('finance','check')">
												<a class="control receivingorder_check" style="display:none" rel="{$vo['receivingorder_id']}" rel2="{$vo.name}" href="javascript:;">{:L('THROUGH_CHECK')}</a>&nbsp;
											<elseif condition="$vo['status'] eq '1' && checkPerByAction('finance','check')"/>
												<a href="{:U('finance/revokecheck', 't=receivingorder&id='.$vo['receivingorder_id'])}">撤销</a>
											<elseif condition="$vo['status'] eq '2' && checkPerByAction('finance','check')"/><a href="{:U('finance/revokecheck', 't=receivingorder&id='.$vo['receivingorder_id'])}">撤销</a>
											</if> -->
										</td>
										<td class="dropdown">
											<span class="dropdown-toggle fa-stack fa-lg" data-toggle="dropdown" style="cursor:pointer;height:3rem;color:#8FA1B2">
												<i class="fa fa-angle-down" style="margin-left:12px;"></i>
											</span>
											<ul class="dropdown-menu">
												<li><a href="javascript:void(0);" rel="{$vo['receivingorder_id']}" class="not_rel_contacts" >删除</a></li>
												<li><a href="{:U('finance/edit',array('t'=>'receivingorder','id'=>$vo['receivingorder_id']))}">编辑</a></li>
												<!-- <if condition="$vo['status'] eq '0' && checkPerByAction('finance','check')">
													<li><a class="control receivingorder_check" rel="{$vo['receivingorder_id']}" rel2="{$vo.name}" href="javascript:;">{:L('THROUGH_CHECK')}</a>&nbsp;</li>
												<elseif condition="$vo['status'] gt '0' && checkPerByAction('finance','check')"/>	
													<li><a href="{:U('finance/revokecheck', 't=receivingorder&id='.$vo['receivingorder_id'])}">撤销</a>&nbsp;</li>
												</if> -->
											</ul>
										</td>
									</tr>
								</volist>
							</tbody>
						</table>
					</div>
				</div>
				<div style="clear:both;"></div>
			</div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-product" title="{:L('ADD_PRODUCT')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-edit" title="{:L('AMENDING_THE_CONTRACT_PRODUCT_INFORMATION')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-receivables" title="{:L('ADD_THE_ACCOUNTS_RECEIVABLE')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-payables" title="{:L('ADD_THE_ACCOUNTS_RECEIVABLE')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-file" title="{:L('ADD_ACCESSORY')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-receivables_plan" title="添加回款计划（应收款剩余金额：{$receivables['un_payable']}）">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-return-sales" title="添加退货单">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-check-info" title="销售合同审核">
	<form action="{:U('contract/check')}" id="deny_form" method="post">
		<input name="contract_id" type="hidden" value="{$info['contract_id']}" />
		<textarea style="width:400px;height:200px;" name="description" placeholder="填写理由(必填)"></textarea>
		<div style="margin-top:10px;margin-right:5px;">
		<a href="javascript:void(0);" onclick="javascript:$('#dialog-check-info').dialog('close');" class="pull-right btn btn-primary">取消</a>
		<button type="submit" name="submit1" value="deny" class="pull-right btn btn-primary" style="margin-right:10px;padding:6px 13px;">确认拒绝</button>&nbsp;&nbsp;
		</div>
	</form>
</div>
<div style="display:none;" id="dialog-receivingorder" title="添加回款单">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-check-list" title="审核记录">
<div style="display:none;" id="dialog-rececheck-info" title="收款单审核">
	<form action="{:U('finance/check','t=receivingorder')}" method="post">
	<input id="dialog_order_id" name="receivingorder_id" type="hidden" value="{$id}" />
	<input name="t" type="hidden" value="receivingorder"/>
		<table class="table">
			<tr>
				<td>
					收款单号：<a href="javascript:;" target="_blank" id="dialog_check_order_no"></a>
					<br/>
					<br/>
					<textarea tabindex="0" style="width:400px;height:200px;" class="form-control" id="dialog_description" name="description" placeholder="填写理由(非必填)"></textarea>
				</td>
			</tr>
			<tr>
				<td style="text-align:center;">
					<button type="submit" name="submit1" value="agree" class="btn btn-primary btn-sm">同意</button> &nbsp; &nbsp; 
					<button type="submit" name="submit1" value="deny" class="btn btn-warning btn-sm">拒绝</button>
				</td>
			</tr>
		</table>
	</form>
</div>
<div style="display:none" id="dialog-check-contract" title="合同审核">
	<form action="" id="contract_dialog" method="post">
		<input id="dialog_order_id" name="contract_id" type="hidden" value="" />
		<input type="hidden" name="m" value="contract">
		<input type="hidden" name="a" value="check">
		<table class="table" style="border:none;">
			<tr>
				<td style="border:none;text-align:right">审核结果：</td>
				<td style="border:none;">
					<select name="is_agree" id="is_agree" style="width:300px;" class="form-control required">
						<option value="1">同意</option>
						<option value="2">拒绝</option>
					</select>
				</td>
			</tr>
			<tr class="is_show">
				<td style="border:none;text-align:right">生成应收款：</td>
				<td style="border:none;">
					<div class="radio radio-info radio-inline" style="padding-left:18px;">
						<input type="radio" name="is_receivables" <if condition="$is_receivables eq 1">checked</if> id="openrecycle" class="openrecycle" value="1"><label for="openrecycle">是</label>
					</div>
					<div class="radio radio-info radio-inline" style="padding-left:18px;">
						<input type="radio" name="is_receivables" <if condition="$is_receivables eq 0">checked</if> id="openrecycle1" class="openrecycle" value="2"><label for="openrecycle1">否</label>&nbsp;
					</div>
				</td>
			</tr>
			<tr class="is_show" id="pay_times">
				<td style="border:none;text-align:right">应收款时间：</td>
				<td style="border:none;">
					<input onclick="WdatePicker()" class="form-control required Wdate" style="width:300px;" type="text" id="pay_time" name="pay_time" value="<?php echo date('Y-m-d', time());?>"/>
				</td>
			</tr>
			<tr>
				<td style="border:none;text-align:right">备注：</td>
				<td style="border:none;">
					<textarea tabindex="0" style="width:300px;height:100px;" class="form-control required" id="dialog_description" name="description" placeholder="填写理由(非必填)"></textarea>
				</td>
			</tr>
		</table>
	</form>
</div>
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/js/litebox.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/images-loaded.min.js" type="text/javascript"></script>
<script type="text/javascript">
	// 页面加载时执行Tab start
	$(function(){
		var thisId = window.location.hash; 
		var atype = thisId.substr(1);
		$('#left_list a[type="'+atype+'"]').tab('show');
	});
	// 页面加载时执行Tab end
	$('#left_list a').click(function (e) {
		var maodian = '#'+$(this).attr('type');
		url_jump(maodian);
	});
	function url_jump(maodian){
	    var order_id = "{$order_info['order_id']}";;
	    var url = "{:U('order/view','id=')}"+order_id+maodian;
	    window.history.replaceState({},0,window.location.protocol + "//"+window.location.host+url);
	}

	var is_receivables = '{$is_receivables}';
	$('#is_agree').change(function(){
		var agree_id = $(this).val();
		if(agree_id == 1){
			$('.is_show').show();
			if(is_receivables == 0 || is_receivables == ''){
				$('#pay_times').hide();
			}
		}else{
			$('.is_show').hide();
		}
	});
	$('.openrecycle').click(function(){
		var is_receivables = $("input[name='is_receivables']:checked").val();
		if(is_receivables == 1){
			$('#pay_times').show();
		}else{
			$('#pay_times').hide();
		}
	});
	$("#check_contract").click(function(){
		var is_checked = $('#is_checked').val();
		var id = $(this).attr('rel');
		if(is_checked == 1){
			var order_id = $(this).attr('rel');
			$("#dialog_check_order_no").attr('href', "{:U('contract/view','id=')}"+order_id);
			$("#dialog_order_id").val(order_id);
			$('#dialog-check-contract').dialog('open');
			$("#dialog_description").focus();
		}else{
			swal({   title: "确定要撤销审核吗？",   type: "warning",   showCancelButton: true,  
			confirmButtonColor: "#DD6B55",   confirmButtonText: "确定",   closeOnConfirm: false },
			function(){ 
				window.location.href="{:U('contract/revokeCheck', 'id=')}"+id; 
			});
		}
	});
	$("#dialog-check-contract").dialog({
		autoOpen: false,
		modal: true,
		width: 444,
		maxHeight: 450,
		position: ["center",100] ,
		buttons: {
			"确定": function () {
				$('#contract_dialog').submit();
				$(this).dialog("close");
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});
	/**
	 * 如果是图片时 双击可查看大图
	 */
	$('.litebox_file').liteBox({
		revealSpeed: 400,
		background: 'rgba(0,0,0,.8)',
		overlayClose: true,
		escKey: true,
		navKey: true,
		errorMessage: '图片加载失败.'
	});
	var pm_heigth = window.screen.height * 0.57;
	var right_heigth = window.screen.height * 0.57;
	$('#left-content').css('min-height',pm_heigth+'px');
	$('#right-content').css('min-height',right_heigth+'px');
	$(".check_badge").hover(function(){
		$(this).find('.control').toggle();
	});
	$('#submit_deny').click(function(){
		$('#dialog-check-info').dialog('open');
	});
	$('#checked_submit').click(function(){
		swal({   title: "确定要通过审核吗？",   type: "warning",   showCancelButton: true,   confirmButtonColor: "#1AB394",   confirmButtonText: "确定",   closeOnConfirm: false },
		function(){   $('#form_submit').submit(); });
	});

	$("#dialog-receivables_plan").dialog({
		autoOpen: false,
		modal: true,
		width: 700,
		maxHeight: 500,
		position: ["center",100],
	});
	$("#dialog-return-sales").dialog({
		autoOpen: false,
		modal: true,
		width: 800,
		maxHeight: 500,
		position: ["center",100],
	});
	$("#dialog-check-list").dialog({
		autoOpen: false,
		modal: true,
		width: 600,
		maxHeight: 400,
		position: ["center",100],
	});
	$(function(){
		$("#check_list").click(function(){
			$('#dialog-check-list').dialog('open');
			$('#dialog-check-list').load('{:U("Contract/check_list","id=".$info["contract_id"])}');
		});
		$(".add_receivables_plan").click(function(){
			$('#dialog-receivables_plan').dialog('open');
			$('#dialog-receivables_plan').load('{:U("finance/adddialog","t=receivablesplan&receivables_id=")}'+$(this).prev().val());
		});
		$('#return_sales').click(function(){
			$('#dialog-return-sales').dialog('open');
			$('#dialog-return-sales').load("{:U('contract/return_sales','id='.$info['contract_id'])}");
		})
	});
	//删除回款单
	$('.not_rel_contacts').click(function(){
		var receivingorder_id = $(this).attr('rel');
		if(receivingorder_id == 0){
			alert_crm('您没有选择任何回款单！');
			return false;
		}
		swal({
			title: "您确定要删除这条信息吗？",
   			text: "删除后将无法恢复，请谨慎操作！",
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "是的，我要删除！",
	        cancelButtonText:'让我再考虑一下…',
	        closeOnConfirm:false,
	        closeOnCancel:false
		},
		function(isConfirm){
	        if (isConfirm) {
	        	$.ajax({
		            type:'post',
		            url: "{:U('finance/delete','t=receivingorder')}",
		            data: {id:receivingorder_id,t:'receivingorder'},
		            async: false,
		            success: function (data) {
						if (data.status == 1) {
							swal("删除成功！", "您已经永久删除了信息！", "success");
							location.reload();
						}else{
							swal({
								title: "操作失败！",
								text:data.info,
								type: "error"
							})
							return false;
						}
		            },
		            dataType: 'json'
		        });
	        } else {
	            swal("已取消","您取消了删除操作！","error");
	        }
	    });
	});
</script>
<script>
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else />width=800;</if>
$("#dialog-product").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight:400,
	position: ["center",100]
});
$("#dialog-edit").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight:400,
	position: ["center",100]
});
$("#dialog-role-info").dialog({
    autoOpen: false,
    modal: true,
	width: 600,
	maxHeight:550,
	position: ["center",100]
});
$("#dialog-receivables").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight:400,
	position: ["center",100]
});
$("#dialog-payables").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight:400,
	position: ["center",100]
});
$("#dialog-file").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100],
	buttons: {
		"确认": function () {
		   location.reload();
		},
		"取消": function () {
			$(this).dialog("close");
		}
	}
});
$("#dialog-check-info").dialog({
	autoOpen: false,
	modal: true,
	width: 432,
	maxHeight: 400,
	position: ["center",100],
});
$("#dialog-rececheck-info").dialog({
	autoOpen: false,
	modal: true,
	width: 450,
	maxHeight: 400,
	position: ["center",100]
});
$(function(){
	$(".edit_product").click(function(){
		id = $(this).attr('rel');
		$('#dialog-edit').dialog('open');
		$('#dialog-edit').load('{:U("product/editdialog","r=RContractProduct&id")}'+id);
	});
	$(".add_product").click(function(){
		$('#dialog-product').dialog('open');
		$('#dialog-product').load('{:U("product/adddialog","r=RContractProduct&module=contract&id=".$info["contract_id"])}');
	});
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
	$(".add_file").click(function(){
		$('#dialog-file').dialog('open');
		$('#dialog-file').load('{:U("file/add","r=RContractFile&module=contract&id=".$info["contract_id"])}');
	});
	$("#add_receivingorder").click(function(){
		$('#dialog-receivingorder').dialog('open');
		$('#dialog-receivingorder').load('{:U("finance/adddialog","t=receivingorder&contract_id=".$info['contract_id'])}');
	});
	$("#dialog-receivingorder").dialog({
		autoOpen: false,
		modal: true,
		width: 540,
		maxHeight: 600,
		position: ["center",100],
		buttons: {
			"确定": function () {
				$('#receivingorder_dialog').submit();
				$(this).dialog("close");
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});
	$(".receivingorder_check").click(function(){
		var order_id = $(this).attr('rel');
		var order_name = $(this).attr('rel2');
		$("#dialog_check_order_no").text(order_name);
		$("#dialog_check_order_no").attr('href', '{:U('finance/view','t=receivingorder&id=')}'+order_id);
		$("#dialog_order_id").val(order_id);
		$("#dialog_description").focus();
		$('#dialog-rececheck-info').dialog('open');
	});
	$(".checkbtn").click(function(){
		$('#dialog-check-info').dialog('open');
		$("#dialog_description").focus();
	})
});
</script>
<include file="Public:footer" />	